<?php
namespace BP\Sys\FrmUI;
require_once("BP/En/Map.php");
class MapAttrString extends EntityMyPK {
	public function getIsSupperText () 
	{
		return $this->GetValBooleanByKey(MapAttrAttr::$IsSupperText);
	}
	public function setIsSupperText ($value) // [boolean value]
	{
		$this->SetValByKey(MapAttrAttr::$IsSupperText, $value);
	}
	public function getIsRichText () 
	{
		return $this->GetValBooleanByKey(MapAttrAttr::$IsRichText);
	}
	public function setIsRichText ($value) // [boolean value]
	{
		$this->SetValByKey(MapAttrAttr::$IsRichText, $value);
	}
	public function getFK_MapData () 
	{
		return $this->GetValStringByKey(MapAttrAttr::$FK_MapData);
	}
	public function setFK_MapData ($value) // [String value]
	{
		$this->SetValByKey(MapAttrAttr::$FK_MapData, $value);
	}
	public function getKeyOfEn () 
	{
		return $this->GetValStringByKey(MapAttrAttr::$KeyOfEn);
	}
	public function setKeyOfEn ($value) // [String value]
	{
		$this->SetValByKey(MapAttrAttr::$KeyOfEn, $value);
	}
	public function getHisUAC () 
	{
		$uac = new UAC();
		$uac->IsInsert =  FALSE ;
		$uac->IsUpdate =  TRUE ;
		$uac->IsDelete =  TRUE ;
		return $uac;
	}
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public static function constructor__String ($myPK) // [String myPK]
	{
		$me = new self();
		$me->setMyPK($myPK);
		$me->Retrieve();
		return $me;
	}
	public function getEnMap () 
	{
		if (($this->get_enMap() != NULL))
		{
			return $this->get_enMap();
		}
		$map = new Map("Sys_MapAttr", "文本字段");
		$map->Java_SetDepositaryOfEntity($Depositary->None);
		$map->Java_SetDepositaryOfMap($Depositary->Application);
		$map->Java_SetEnType($EnType->Sys);
		$map->AddTBStringPK(MapAttrAttr::$MyPK, NULL, "主键",  FALSE ,  FALSE , 0, 200, 20);
		$map->AddTBString(MapAttrAttr::$FK_MapData, NULL, "表单ID",  FALSE ,  FALSE , 1, 100, 20);
		$map->AddTBString(MapAttrAttr::$Name, NULL, "字段中文�?",  TRUE ,  FALSE , 0, 200, 20,  TRUE );
		$map->AddTBString(MapAttrAttr::$KeyOfEn, NULL, "字段�?",  TRUE ,  TRUE , 1, 200, 20);
		$sql = "SELECT No,Name FROM Sys_GloVar WHERE GroupKey='DefVal'";
		$map->AddDDLSQL("ExtDefVal", "0", "系统默认�?", $sql,  TRUE );
		$map->AddTBString(MapAttrAttr::$DefVal, NULL, "默认值表达式",  TRUE ,  FALSE , 0, 400, 20,  TRUE );
		$map->AddTBInt(MapAttrAttr::$MinLen, 0, "�?小长�?",  TRUE ,  FALSE );
		$map->AddTBInt(MapAttrAttr::$MaxLen, 50, "�?大长�?",  TRUE ,  FALSE );
		$map->AddTBFloat(MapAttrAttr::$UIWidth, 100, "宽度",  TRUE ,  FALSE );
		$map->AddTBFloat(MapAttrAttr::$UIHeight, 23, "高度",  TRUE ,  FALSE );
		$map->AddBoolean(MapAttrAttr::$UIVisible,  TRUE , "是否可见�?",  TRUE ,  TRUE );
		$map->AddBoolean(MapAttrAttr::$UIIsEnable,  TRUE , "是否可编辑？",  TRUE ,  TRUE );
		$map->AddBoolean(MapAttrAttr::$UIIsInput,  FALSE , "是否必填项？",  TRUE ,  TRUE );
		$map->AddBoolean(MapAttrAttr::$IsRichText,  FALSE , "是否富文本？",  TRUE ,  TRUE );
		$map->AddBoolean(MapAttrAttr::$IsSupperText,  FALSE , "是否大块文本�?(是否该字段存放的超长字节字段)",  TRUE ,  TRUE ,  TRUE );
		$map->AddTBString(MapAttrAttr::$Tip, NULL, "�?活提�?",  TRUE ,  FALSE , 0, 400, 20,  TRUE );
		$map->AddDDLSysEnum(MapAttrAttr::$ColSpan, 1, "单元格数�?",  TRUE ,  TRUE , "ColSpanAttrDT", "@0=�?0个单元格@1=�?1个单元格@2=�?2个单元格@3=�?3个单元格@4=�?4个单元格@5=�?4个单元格@6=�?4个单元格");
		$map->AddDDLSysEnum(MapAttrAttr::$TextColSpan, 1, "文本单元格数�?",  TRUE ,  TRUE , "ColSpanAttrString", "@1=�?1个单元格@2=�?2个单元格@3=�?3个单元格@4=�?4个单元格@5=�?4个单元格@6=�?4个单元格");
		$map->AddTBInt(MapAttrAttr::$RowSpan, 1, "行数",  TRUE ,  FALSE );
		$map->AddDDLSQL(MapAttrAttr::$GroupID, 0, "显示的分�?", MapAttrString::getSQLOfGroupAttr(),  TRUE );
		$map->AddDDLSysEnum(MapAttrAttr::$IsSigan, 0, "签名模式",  TRUE ,  TRUE , MapAttrAttr::$IsSigan, "@0=无@1=图片签名@2=山东CA@3=广东CA@4=图片盖章");
		$map->AddTBInt(MapAttrAttr::$Idx, 0, "顺序�?",  TRUE ,  FALSE );
		$rm = new RefMethod();
		$rm = new RefMethod();
		$rm->Title = "正则表达�?";
		$rm->ClassMethodName = ($this . ".DoRegularExpression()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "文本框自动完�?";
		$rm->ClassMethodName = ($this . ".DoTBFullCtrl2019()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "脚本验证";
		$rm->ClassMethodName = ($this . ".DoInputCheck()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "事件绑函�?";
		$rm->ClassMethodName = ($this . ".BindFunction()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "超链�?";
		$rm->ClassMethodName = ($this . ".DoLink()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "快�?�录�?";
		$rm->ClassMethodName = ($this . ".DoFastEnter()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "全局默认�?";
		$rm->ClassMethodName = ($this . ".DoDefVal()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "字段重命�?";
		$rm->ClassMethodName = ($this . ".DoRenameField()");
		$rm->getHisAttrs()->AddTBString("key1", "@KeyOfEn", "字段重命名为?",  TRUE ,  FALSE , 0, 100, 100);
		$rm->refMethodType = $RefMethodType->Func;
		$rm->Warning = "如果是节点表单，系统就会把该流程上的�?有同名的字段都会重命名，包括NDxxxRpt表单�?";
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "Pop返回�?";
		$rm->ClassMethodName = ($this . ".DoPop2019()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->GroupName = "输入内容多�??";
		$rm->Title = "小范围多�?(combox)";
		$rm->ClassMethodName = ($this . ".DoMultipleChoiceSmall()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->GroupName = "输入内容多�??";
		$rm->Title = "搜索多�??";
		$rm->ClassMethodName = ($this . ".DoMultipleChoiceSearch()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "扩展控件";
		$rm->ClassMethodName = ($this . ".DoEditFExtContral()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$rm->GroupName = "高级设置";
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "扩展控件2019";
		$rm->ClassMethodName = ($this . ".DoEditFExtContral2019()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$rm->GroupName = "高级设置";
		$map->AddRefMethod($rm);
		$rm = new RefMethod();
		$rm->Title = "批处�?";
		$rm->ClassMethodName = ($this . ".DoEleBatch()");
		$rm->refMethodType = $RefMethodType->RightFrameOpen;
		$rm->GroupName = "高级设置";
		$map->AddRefMethod($rm);
		$this->set_enMap($map);
		return $this->get_enMap();
	}
	public static function getSQLOfGroupAttr () 
	{
		return "SELECT OID as No, Lab as Name FROM Sys_GroupField WHERE FrmID='@FK_MapData'  AND (CtrlType IS NULL OR CtrlType='')  ";
	}
	protected function afterDelete () 
	{
		$sql = (((("DELETE FROM Sys_MapAttr WHERE FK_MapData='" . $this->getFK_MapData()) . "' AND KeyOfEn='") . $this->getKeyOfEn()) . "T'");
		DBAccess::RunSQL($sql);
		if ((DBAccess->IsExitsTableCol("Sys_FrmImg", "KeyOfEn") ==  TRUE ))
		{
			$sql = (((("DELETE FROM Sys_FrmImg WHERE FK_MapData='" . $this->getFK_MapData()) . "' AND KeyOfEn='") . $this->getKeyOfEn()) . "T'");
		}
		DBAccess::RunSQL($sql);
		if (($this->getFK_MapData()->contains("ND") ==  TRUE ))
		{
			$fk_mapData = ($this->getFK_MapData()->substring(0, ($this->getFK_MapData()->length() - 2)) . "Rpt");
			$sql = (((((("DELETE FROM Sys_MapAttr WHERE FK_MapData='" . $fk_mapData) . "' AND( KeyOfEn='") . $this->getKeyOfEn()) . "T' OR KeyOfEn='") . $this->getKeyOfEn()) . "')");
			DBAccess::RunSQL($sql);
		}
		CCFormAPI->AfterFrmEditAction($this->getFK_MapData());
		parent->afterDelete();
	}
	protected function afterInsertUpdateAction () 
	{
		$mapAttr = MapAttr::constructor__();
		$mapAttr->setMyPK($this->getMyPK());
		$mapAttr->RetrieveFromDBSources();
		$mapAttr->Update();
		CCFormAPI->AfterFrmEditAction($this->getFK_MapData());
		parent->afterInsertUpdateAction();
	}
	public function DoRenameField ($newField) // [String newField]
	{
		$sql = "";
		if (($this->getFK_MapData()->indexOf("ND") == 0))
		{
			$strs = $this->getFK_MapData()->replace("ND", "");
			$strs = $strs->substring(0, ($strs->length() - 2));
			$rptTable = (("ND" . $strs) . "Rpt");
			$mds = MapDatas::constructor__();
			$mds->Retrieve(MapDataAttr::$PTable, $rptTable);
			foreach ($mds->ToJavaList() as $item) 			{
				$sql = (((((((((("UPDATE Sys_MapAttr SET KeyOfEn='" . $newField) . "',  MyPK='") . $newField) . "_") . $item->getNo()) . " WHERE KeyOfEn='") . $this->getKeyOfEn()) . "' AND FK_MapData='") . $item->getNo()) . "'");
				DBAccess::RunSQL($sql);
			}
		}
		else
		{
			$sql = (((((((((("UPDATE Sys_MapAttr SET KeyOfEn='" . $newField) . "', MyPK='") . $newField) . "_") . $this->getFK_MapData()) . "  WHERE KeyOfEn='") . $this->getKeyOfEn()) . "' AND FK_MapData='") . $this->getFK_MapData()) . "'");
			DBAccess::RunSQL($sql);
		}
		return "重名称成�?,如果是自由表单，请关闭表单设计器重新打开.";
	}
	public function BindFunction () 
	{
		return ((("../../Admin/FoolFormDesigner/MapExt/BindFunction.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn());
	}
	public function DoFastEnter () 
	{
		return ((("../../Admin/FoolFormDesigner/MapExt/FastInput.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn());
	}
	public function DoPop2019 () 
	{
		return ((("../../Admin/FoolFormDesigner/Pop/Default.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn());
	}
	public function DoDefVal () 
	{
		return ((("../../Admin/FoolFormDesigner/DefVal.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn());
	}
	public function DoPopFullCtrl () 
	{
		return ((((("../../Admin/FoolFormDesigner/MapExt/PopFullCtrl.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn()) . "&MyPK=TBFullCtrl_") . $this->getMyPK());
	}
	public function DoPopFullCtrlAdv () 
	{
		return ((((("../../Admin/FoolFormDesigner/MapExt/PopFullCtrl.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn()) . "&MyPK=TBFullCtrl_") . $this->getMyPK());
	}
	public function DoEleBatch () 
	{
		return ((((("../../Admin/FoolFormDesigner/EleBatch.htm?EleType=MapAttr&KeyOfEn=" . $this->getKeyOfEn()) . "&FType=1&MyPK=") . $this->getMyPK()) . "&FK_MapData=") . $this->getFK_MapData());
	}
	public function DoMultipleChoiceSmall () 
	{
		return (((("../../Admin/FoolFormDesigner/MapExt/MultipleChoiceSmall.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn()) . "&m=s");
	}
	public function DoMultipleChoiceSearch () 
	{
		return (((("../../Admin/FoolFormDesigner/MapExt/MultipleChoiceSearch.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn()) . "&m=s");
	}
	public function DoLink () 
	{
		return ((((((((("../../Admin/FoolFormDesigner/MapExt/Link.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn()) . "&MyPK=") . $this->getMyPK()) . "&FK_MapExt=Link_") . $this->getFK_MapData()) . "_") . $this->getKeyOfEn());
	}
	public function DoPopVal () 
	{
		return ((((((((("../../Admin/FoolFormDesigner/MapExt/PopVal.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn()) . "&MyPK=") . $this->getMyPK()) . "&FK_MapExt=PopVal_") . $this->getFK_MapData()) . "_") . $this->getKeyOfEn());
	}
	public function DoRegularExpression () 
	{
		return ((((("../../Admin/FoolFormDesigner/MapExt/RegularExpression.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn()) . "&MyPK=") . $this->getMyPK());
	}
	public function DoTBFullCtrl2019 () 
	{
		return ((((("../../Admin/FoolFormDesigner/TBFullCtrl/Default.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn()) . "&MyPK=TBFullCtrl_") . $this->getMyPK());
	}
	public function DoInputCheck () 
	{
		return (((((("../../Admin/FoolFormDesigner/MapExt/InputCheck.htm?FK_MapData=" . $this->getFK_MapData()) . "&OperAttrKey=") . $this->getKeyOfEn()) . "&RefNo=") . $this->getMyPK()) . "&DoType=New&ExtType=InputCheck");
	}
	public function DoEditFExtContral () 
	{
		return ((((("../../Admin/FoolFormDesigner/EditFExtContral.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn()) . "&MyPK=") . $this->getMyPK());
	}
	public function DoEditFExtContral2019 () 
	{
		return ((((("../../Admin/FoolFormDesigner/EditFExtContral/Default.htm?FK_MapData=" . $this->getFK_MapData()) . "&KeyOfEn=") . $this->getKeyOfEn()) . "&MyPK=") . $this->getMyPK());
	}
	protected function beforeUpdateInsertAction () 
	{
		$attr = MapAttr::constructor__();
		$attr->setMyPK($this->getMyPK());
		$attr->RetrieveFromDBSources();
		$attr->setIsRichText($this->GetValBooleanByKey(MapAttrAttr::$IsRichText));
		$attr->setIsSupperText($this->GetValBooleanByKey(MapAttrAttr::$IsSupperText));
		if (($attr->getIsRichText() || $attr->getIsSupperText()))
		{
			$attr->setMaxLen(4000);
			$this->SetValByKey(MapAttrAttr::$MaxLen, 4000);
		}
		if (($attr->getMaxLen() < 4000))
		{
			$sql = "";
			$md = MapData::constructor__();
			$md->setNo($this->getFK_MapData());
			if (($md->RetrieveFromDBSources() == 1))
			{
				if ((DBAccess->IsExitsTableCol($md->getPTable(), $this->getKeyOfEn()) ==  TRUE ))
				{
					if ((SystemConfig::getAppCenterDBType() == $DBType->MSSQL))
					{
						$sql = (((((("ALTER TABLE " . $md->getPTable()) . " ALTER column ") . $this->getKeyOfEn()) . " NVARCHAR(") . $attr->getMaxLen()) . ")");
					}
					if ((SystemConfig::getAppCenterDBType() == $DBType->MySQL))
					{
						$sql = (((((("alter table " . $md->getPTable()) . " modify ") . $attr->getField()) . " NVARCHAR(") . $attr->getMaxLen()) . ")");
					}
					if ((SystemConfig::getAppCenterDBType() == $DBType->Oracle))
					{
						$sql = (((((("alter table " . $md->getPTable()) . " modify ") . $attr->getField()) . " NVARCHAR2(") . $attr->getMaxLen()) . ")");
					}
					if ((SystemConfig::getAppCenterDBType() == $DBType->PostgreSQL))
					{
						$sql = (((((("alter table " . $md->getPTable()) . " alter ") . $attr->getField()) . " type character varying(") . $attr->getMaxLen()) . ")");
					}
					DBAccess::RunSQL($sql);
				}
			}
		}
		$defval = $this->GetValStrByKey("ExtDefVal");
		if (($defval->equals("") || $defval->equals("0")))
		{
			$defVal = $this->GetValStrByKey("DefVal");
			if (($defval->contains("@") ==  TRUE ))
			{
				$this->SetValByKey("DefVal", "");
			}
		}
		else
		{
			$this->SetValByKey("DefVal", $this->GetValByKey("ExtDefVal"));
		}
		$attr->Save();
		if ($this->GetValStrByKey("GroupID")->equals("�?"))
		{
			$this->SetValByKey("GroupID", "0");
		}
		return parent->beforeUpdateInsertAction();
	}
}
?>
